package insight.jsp.custom.taglib;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;

import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.commons.io.IOUtils;

public class LeftPanelTagHandler extends TagSupport {
	private static final long serialVersionUID = 1L;

	@Override
	public int doStartTag() {
		try {
			JspWriter out = pageContext.getOut();
			
			String strOut = buildOutput("leftPanel.inc");
			out.println(strOut);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}

	private String buildOutput(String fileName) {
		InputStream in = this.getClass().getClassLoader()
				.getResourceAsStream(fileName);
		StringWriter writer = new StringWriter();
		try {
			IOUtils.copy(in, writer, "UTF-8");
		} catch (IOException e) {
			e.printStackTrace();
		}
		String strOut = writer.toString();
		
		return strOut;
	}
}
